#include<iostream>
#include<unistd.h>
#include<pthread.h>

using namespace std;

void* pthread_run(void* args)
{
    cout <<args<<endl;
    char* str = (char*) args;
    while(true)
    {
        cout<<"new thread is runing, tname: "<< str <<endl;
        sleep(1);
    }
}

int main()
{
    pthread_t thread;
    for(int i = 0;i<10;i++)
    {
        char* tname = new char[64];
        snprintf(tname,64,"tname-%d",i+1);
        pthread_create(&thread,nullptr,pthread_run,tname);
    }

    while(true)
    {
        cout<< "I am main thread , I am running "<<endl;
        sleep(1);
    }
    return 0;
}